package com.study.lk.exe2;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * @author lk
 * @date 2021/4/16 0016 14:37
 * @description:
 */
public class UpperInputStream extends FilterInputStream {

    protected UpperInputStream(InputStream in) {
        super(in);
    }


    @Override
    public int read() throws IOException{
        int ch = super.read();
        if (ch >= 'a' && ch <= 'z'){
            ch = Character.toUpperCase(ch);
        }
        return ch;
    }

    @Override
    public int read(byte[] b) throws IOException {
        int ch = super.read(b);
        for (int i=0;i<b.length;i++) {
            if (b[i] >= 'a' && b[i] <= 'z'){
                b[i] = (byte)Character.toUpperCase(b[i]);
            }
        }
        return ch;
    }


}
